package com.vinny.springbootflowable2.listener;

import org.flowable.engine.delegate.TaskListener;
import org.flowable.engine.impl.el.FixedValue;
import org.flowable.task.service.delegate.DelegateTask;

public class GroupTaskListener implements TaskListener {
    
    private FixedValue candidateGroups;

    @Override
    public void notify(DelegateTask delegateTask) {
        // 从字段中获取候选组
        String groupId = (String) delegateTask.getVariable("candidateGroups");
        if (groupId == null && candidateGroups != null) {
            groupId = (String) candidateGroups.getValue(delegateTask);
        }
        // 设置任务的候选组
        if (groupId != null) {
            delegateTask.addCandidateGroup(groupId);
        }
    }

    public void setCandidateGroups(FixedValue candidateGroups) {
        this.candidateGroups = candidateGroups;
    }
} 